package com.dragon.repository.domain.dto;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.Admin;
import com.dragon.repository.entity.Mod;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;


/**
 * @author sy
 */
@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
public class AdminDTO {

    private static final long serialVersionUID = 1L;

    private Integer id;

    @ApiModelProperty(value = "用户名")
    private String username;

//    @ApiModelProperty(value = "密码")
//    private String password;

    @ApiModelProperty(value = "头像")
    private String img;

    @ApiModelProperty(value = "账号")
    private String account;

    @ApiModelProperty(value = "账号状态：1启用2禁用")
    private Integer state;

    @ApiModelProperty(value = "账号类型：1管理员2普通用户")
    private Integer accountType;

    @ApiModelProperty(value = "删除标识：0未删除 1已删除")
    private Integer deleted;

    @ApiModelProperty(value = "创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty(value = "修改时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty(value = "手机号码")
    private String phone;

    @ApiModelProperty(value = "角色名称")
    private String roleName;

    @ApiModelProperty(value = "岗位名称")
    private String positionName;

    @ApiModelProperty(value = "部门名称")
    private String departmentName;

    @ApiModelProperty(value = "部门id")
    private Integer departmentId;

    @ApiModelProperty(value = "岗位id")
    private Integer positionId;

    @ApiModelProperty(value = "菜单集合")
    private List<MenuDTO> menuList;

    @ApiModelProperty(value = "按钮集合")
    private List<String> bonttonList;

    @ApiModelProperty(value = "角色集合")
    private Integer roleId;

    @ApiModelProperty(value = "部门ids集合")
    private List<Integer> departmentIds;

    @ApiModelProperty(value = "模块集合")
    private List<Mod> modList;

    public AdminDTO() {}

    public AdminDTO(Admin entity) {
        BeanUtils.copyProperties(entity,this);
    }

    public static AdminDTO convert(Admin entity) {
        return new AdminDTO(entity);
    }

    public static List<AdminDTO> convertList(List<Admin> list) {
        List<AdminDTO> resultList = new ArrayList<>();
        for (Admin entity : list) {
            resultList.add(new AdminDTO(entity));
        }
        return resultList;
    }}
